package com.example.blog.controller;

import com.example.blog.dto.*;
import com.example.blog.dto.base.IdRequestDto;
import com.example.blog.response.ResponseModelDto;
import com.example.blog.response.ResponseModels;
import com.example.blog.service.CommunCommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Admin
 */
@RestController
@Api(value = "聊天记录接口", tags = "聊天记录接口")
@RequestMapping("/comment")
public class CommunCommentController {

    @Resource
    private CommunCommentService communCommentService;

    @PostMapping("/addComment")
    @ApiOperation("添加聊天记录接口")
    public ResponseModelDto addComment(@RequestBody @Validated AddCommentReqDto reqDto){
        if(communCommentService.addComment(reqDto)){
            return ResponseModels.ok();
        }else{
            return ResponseModels.commonException("添加失败");
        }
    }

    @GetMapping("/getComment")
    @ApiOperation("查询聊天记录接口")
    public ResponseModelDto<List<QueryCommentResDto>> getComment(@Validated IdRequestDto reqDto){
        return ResponseModels.ok(communCommentService.getComment(reqDto));
    }

}
